import Data.List
primes = 2 : filter ( (==1) . length . primeFactors ) [3,5..]

primeFactors :: Integer -> [Integer]
primeFactors n = factor n primes
	where
	factor n (p:ps)
		| p*p > n		 = [n]
		| n `mod` p == 0 = p : factor ( n `div` p )	(p:ps)
		| otherwise		 = factor n ps

numberOfDivisors n = product $ map ( (+1) . length ) (group (primeFactors n) )

triangleNumbers = scanl (+) 1 [2..]

euler_012 = head $ filter ( (> 500) . numberOfDivisors ) triangleNumbers